package pocker;

import pocker.exceptions.*;

/**
 * Created with IntelliJ IDEA.
 * User: gia
 * Date: 23.08.2012
 * Time: 11:51
 */
public class GameRunner {


    public static void main(String[] args) throws InvalidPlayerNameException, InvalidPlayerCardException, InvalidPlayerException, IsDrawException, OutOfCardsException {
        new GameRunner().runGame();
    }

    private void runGame() throws InvalidPlayerCardException, InvalidPlayerNameException, InvalidPlayerException, IsDrawException, OutOfCardsException {

        IDealer dealer = new ShuffleFirstDealer();
        Player first = new Player(dealer, "firstPlayer"), second = new Player(dealer, "secondPlayer");
        Game game = new Game(first, second);

        System.out.println("Starting game between players: " + first.getName() + " and " + second.getName());

        if (game.isDraw())
            System.out.println("It's a draw between players: " + first.getName() + " and " + second.getName());
        else
            System.out.println("Winner: " + game.getWinner().getName());

        game.save(new GameSerializerImpl());
    }
}
